package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class HomePage extends BasePage {
    public static final String URL = "http://rozetka.com.ua/";

    public HomePage (WebDriver driver) {
        super(driver, URL);
    }

    public void open()
    {
        driver.get(URL);
    }

    public boolean isLoaded() {
        return driver.findElements(By.cssSelector(".copy")).size() == 1;
    }

    public SectionNotebookPage openNotebooksSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Ноутбуки, планшеты и компьютеры')]")).click();
        return new SectionNotebookPage(driver);
    }

    public SectionAppliancesPage openAppliancesSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Бытовая техника и интерьер')]")).click();
        return new SectionAppliancesPage(driver);
    }

    public SectionCaritemsPage openCaritemsSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Автотовары')]")).click();
        return new SectionCaritemsPage(driver);
    }

    public SectionChildrenPage openChildrenSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Детский мир')]")).click();
        return new SectionChildrenPage(driver);
    }

    public SectionGardenPage openGardenSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Дом, сад')]")).click();
        return new SectionGardenPage(driver);
    }

    public SectionMobilePage openMobileSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Телефоны, MP3, GPS')]")).click();
        return new SectionMobilePage(driver);
    }

    public SectionOutdoorPage openOutdoorSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Активный отдых и туризм')]")).click();
        return new SectionOutdoorPage(driver);
    }

    public SectionPhotoPage openPhotoSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Аудио/Видео, ТВ, Фото, муз. инструменты')]")).click();
        return new SectionPhotoPage(driver);
    }

    public SectionShoesPage openShoesSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Обувь')]")).click();
        return new SectionShoesPage(driver);
    }

    public SectionTicketsPage openTicketsSection() {
        driver.findElement(By.xpath ("//span[@class='m-main-title-text' and contains(text(),'Авиа и ЖД билеты')]")).click();
        return new SectionTicketsPage(driver);
    }
    public String getURL() {
        return URL;
    }
}

